package com.eoi.docs;

import com.eoi.docs.conf.ApiConf;
import com.eoi.docs.util.DocsUtils;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class ApiDocsGenApplication implements CommandLineRunner {

    private final ApiConf apiConf;

    public ApiDocsGenApplication(ApiConf apiConf) {
        this.apiConf = apiConf;
    }

    public static void main(String[] args) {
        SpringApplication.run(ApiDocsGenApplication.class, args);
    }

    @Override
    public void run(String... args) throws Exception {

        String url = apiConf.getSwaggerUrl();
        String fileName = apiConf.getFileName();
        String outPath = apiConf.getOutPath();

        DocsUtils.markdown(fileName, url, outPath);
        DocsUtils.confluence(fileName, url, outPath);
        DocsUtils.document(fileName, url, outPath);
    }
}
